package com.mofeng.myshop.domain.dto;

import com.mofeng.myshop.domain.dto.base.BaseDto;
import com.mofeng.myshop.domain.po.Setting;
import com.mofeng.myshop.until.MyUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 网站基础设置
 * </p>
 *
 * @author MoFeng
 * @since 2024-04-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Builder(toBuilder = true)
@Schema(name = "Setting对象", description = "网站基础设置")
public class SettingDto extends BaseDto {
    @Schema(description = "键")
    private String key;

    @Schema(description = "值")
    private String value;

    public Setting toSetting() {
        Setting setting = new Setting();
        toBaseEntity(setting);
        if (!MyUtil.StringUtil.isEmpty(key)) {
            setting.setKey(key);
        }
        if (!MyUtil.StringUtil.isEmpty(value)) {
            setting.setValue(value);
        }
        return setting;
    }
}
